#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：图灵学习 
@File    ：3.获取进程的编号.py
@IDE     ：PyCharm 
@Author  ：ChenLiGao
@Date    ：2024-11-05 15:08
'''
import os

import multiprocessing

def get_pid():
    print(f"子进程pid编号为：{os.getpid()}，主进程编号为：{os.getppid()}")

if __name__ == '__main__':
    p = multiprocessing.Process(target=get_pid)
    p.start()
    print("主进程编号：",os.getpid())

    # 获取运行python程序的进程
    print("pycharm进程编号：", os.getppid())

